package com.kinyx.hibernate.type;

import java.util.BitSet;

import org.hibernate.dialect.Dialect;
import org.hibernate.type.AbstractSingleColumnStandardBasicType;
import org.hibernate.type.DiscriminatorType;
import org.hibernate.type.descriptor.sql.VarcharTypeDescriptor;

import com.kinyx.hibernate.TypeStatics;
import com.kinyx.hibernate.type.descriptor.java.BitSetBasicTypeDescriptor;

@SuppressWarnings("serial")
public class BitSetBasicType extends AbstractSingleColumnStandardBasicType<BitSet> implements DiscriminatorType<BitSet> {

	public static final BitSetBasicType INSTANCE = new BitSetBasicType();

	public BitSetBasicType() {
		super(VarcharTypeDescriptor.INSTANCE, BitSetBasicTypeDescriptor.INSTANCE);
	}

	@Override
	public BitSet stringToObject(final String xml) throws Exception {
		return this.fromString(xml);
	}

	@Override
	public String objectToSQLString(final BitSet value, final Dialect dialect) throws Exception {
		return this.toString(value);
	}

	@Override
	public String getName() {
		return TypeStatics.BIT_SET;
	}

}
